home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / fpc / inc / systemh.inc < prev    next >
Text File  |  1998-09-21  |  18KB  |  509 lines

  1. {
  2.     $Id: systemh.inc,v 1.24 1998/08/11 21:39:08 peter Exp $
  3.     This file is part of the Free Pascal Run time library.
  4.     Copyright (c) 1993,97 by the Free Pascal development team
  5.  
  6.     See the File COPYING.FPC, included in this distribution,
  7.     for details about the copyright.
  8.  
  9.     This program is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12.  
  13.  **********************************************************************}
  14.  
  15. {*****************************************************************************
  16.    This File contains the OS independent declarations of the system unit
  17.  
  18.    Possible defines:
  19.    -----------------
  20.    RTLLITE         Create a somewhat smaller RTL
  21.  
  22. *****************************************************************************}
  23.  
  24.  
  25. {****************************************************************************
  26.                    Support for multiple compiler versions
  27. ****************************************************************************}
  28.  
  29. {$i version.inc}
  30.  
  31. {****************************************************************************
  32.                          Global Types and Constants
  33. ****************************************************************************}
  34.  
  35. Type
  36.   Longint  = $80000000..$7fffffff;
  37.   Integer  = -32768..32767;
  38.   shortint = -128..127;
  39.   byte     = 0..255;
  40.   Word     = 0..65535;
  41.  
  42. { at least declare Turbo Pascal real types }
  43. {$ifdef i386}
  44.   {$ifndef VER0_99_5}
  45.     {$ifndef VER0_99_6}
  46.       {$define DEFAULT_EXTENDED}
  47.     {$endif}
  48.   {$endif}
  49.   {$define SUPPORT_EXTENDED}
  50.   {$define SUPPORT_COMP}
  51.   {$define SUPPORT_SINGLE}
  52.   {$define SUPPORT_FIXED}
  53.   Double = real;
  54.   {$ifdef DEFAULT_EXTENDED}
  55.     ValReal = Extended;
  56.   {$else}
  57.     ValReal = Double;
  58.   {$endif}
  59. {$endif}
  60.  
  61. {$ifdef m68k}
  62.    StrLenInt = Integer;
  63.    ValReal = Real;
  64.    {$ifdef USEANSISTRINGS}
  65.       {$error StrLenInt must be a longint if ansi strings are used}
  66.    {$endif}
  67. {$endif}
  68.  
  69. {$ifdef i386}
  70.    StrLenInt = LongInt;
  71. {$endif}
  72. { some type aliases }
  73.   dword    = cardinal;
  74.   longword = cardinal;
  75.  
  76. { Zero - terminated strings }
  77.   PChar  = ^Char;
  78.   PPChar = ^PChar;
  79.  
  80. { procedure type }
  81.   TProcedure = Procedure;
  82.  
  83. const
  84. { max. values for longint and int}
  85.   maxLongint = $7fffffff;
  86.   maxint = 32767;
  87.  
  88. { Compatibility With  TP }
  89. {$ifdef i386}
  90.   Test8086 : byte = 2;       { Always i386 or newer }
  91.   Test8087 : byte = 3;       { Always 387 or newer. Emulated if needed. }
  92. {$endif i386}
  93. {$ifdef m68k}
  94.   Test68000 : byte = 0;      { Must be determined at startup for both }
  95.   Test68881 : byte = 0;
  96. {$endif}
  97.  
  98. { max level in dumping on error }
  99.   Max_Frame_Dump : Word = 8;
  100. { Exit Procedure handling consts and types  }
  101.   ExitProc : pointer=nil;
  102.   Erroraddr: pointer = nil;
  103.   Errorcode: Word    = 0;
  104.  
  105. { file input modes }
  106.   fmClosed = $D7B0;
  107.   fmInput  = $D7B1;
  108.   fmOutput = $D7B2;
  109.   fmInOut  = $D7B3;
  110.   fmAppend = $D7B4;
  111.   Filemode : byte = 2;
  112.  
  113. Type TErrorProc = Procedure (ErrNo : Longint; Address : Pointer);
  114.  
  115. var
  116. { Standard In- and Output }
  117.   Output,
  118.   Input,
  119.   StdErr      : Text;
  120.   ExitCode,
  121.   InOutRes    : Word;
  122.   StackBottom,
  123.   LowestStack,
  124.   RandSeed    : Longint;
  125.  
  126. Const
  127.   ErrorProc   : Pointer = nil;
  128.  
  129. {****************************************************************************
  130.                         Processor specific routines
  131. ****************************************************************************}
  132.  
  133. Procedure Move(Var source,dest;count:Longint);
  134. Procedure FillChar(Var x;count:Longint;Value:Char);
  135. Procedure FillChar(Var x;count:Longint;Value:byte);
  136. {$ifndef RTLLITE}
  137. Procedure FillWord(Var x;count:Longint;Value:Word);
  138. {$endif RTLLITE}
  139.  
  140. {****************************************************************************
  141.                                                            Math Routines
  142. ****************************************************************************}
  143.  
  144. {$ifndef RTLLITE}
  145. Function  lo(w:Word):byte;
  146. Function  lo(l:Longint):Word;
  147. Function  lo(i:Integer):byte;
  148. Function  lo(B: Byte):Byte;
  149. Function  hi(w:Word):byte;
  150. Function  hi(i:Integer):byte;
  151. Function  hi(l:Longint):Word;
  152. Function  Hi(B : Byte): byte;
  153. Function  Swap (X:Word):Word;
  154. Function  Swap (X:Integer):Integer;
  155. Function  Swap (X:Cardinal):Cardinal;
  156. Function  Swap (X:Longint):Longint;
  157.  
  158. {$ifdef VER0_99_5}
  159. Procedure Inc(Var i:cardinal);
  160. Procedure Inc(Var i:Longint);
  161. Procedure Inc(Var i:Integer);
  162. Procedure Inc(Var i:Word);
  163. Procedure Inc(Var i:shortint);
  164. Procedure Inc(Var i:byte);
  165. Procedure Inc(Var c:Char);
  166. Procedure Inc(Var p:PChar);
  167. Procedure Dec(Var i:cardinal);
  168. Procedure Dec(Var i:Longint);
  169. Procedure Dec(Var i:Integer);
  170. Procedure Dec(Var i:Word);
  171. Procedure Dec(Var i:shortint);
  172. Procedure Dec(Var i:byte);
  173. Procedure Dec(Var c:Char);
  174. Procedure Dec(Var p:PChar);
  175. Procedure Dec(Var i:cardinal;a:Longint);
  176. Procedure Inc(Var i:cardinal;a:Longint);
  177. Procedure Dec(Var i:Longint;a:Longint);
  178. Procedure Inc(Var i:Longint;a:Longint);
  179. Procedure Dec(Var i:Word;a:Longint);
  180. Procedure Inc(Var i:Word;a:Longint);
  181. Procedure Dec(Var i:Integer;a:Longint);
  182. Procedure Inc(Var i:Integer;a:Longint);
  183. Procedure Dec(Var i:byte;a:Longint);
  184. Procedure Inc(Var i:byte;a:Longint);
  185. Procedure Dec(Var i:shortint;a:Longint);
  186. Procedure Inc(Var i:shortint;a:Longint);
  187. Procedure Dec(Var c:Char;a:Longint);
  188. Procedure Inc(Var c:Char;a:Longint);
  189. Procedure Dec(Var p:PChar;a:Longint);
  190. Procedure Inc(Var p:PChar;a:Longint);
  191. {$endif VER0_99_5}
  192.  
  193. {$endif RTLLITE}
  194. Function Chr(b:byte):Char;
  195. Function Length(s:string):byte;
  196.  
  197. Function  Random(l:Longint):Longint;
  198. Function  Random:real;
  199. Procedure Randomize;
  200.  
  201. Function abs(l:Longint):Longint;
  202. Function sqr(l:Longint):Longint;
  203. Function odd(l:Longint):Boolean;
  204. { float mathe routines }
  205. {$I mathh.inc}
  206.  
  207.  
  208. {****************************************************************************
  209.                                                          Memory management
  210. ****************************************************************************}
  211.  
  212. Procedure getmem(Var p:pointer;Size:Longint);
  213. Procedure freemem(Var p:pointer;Size:Longint);
  214. Function  memavail:Longint;
  215. Function  maxavail:Longint;
  216.  
  217. {$ifndef RTLLITE}
  218. Function  ptr(sel,off:Longint):pointer;
  219. Function  Addr (Var X):pointer;
  220. Function  Cseg:Word;
  221. Function  Dseg:Word;
  222. Function  Sseg:Word;
  223. {$endif RTLLITE}
  224.  
  225. {****************************************************************************
  226.                                                           PChar Handling
  227. ****************************************************************************}
  228.  
  229. function strpas(p:pchar):string;
  230. function strlen(p:pchar):longint;
  231.  
  232.  
  233. Function  Copy(const s:string;index:StrLenInt;count:StrLenInt):string;
  234. Procedure Delete(Var s:string;index:StrLenInt;count:StrLenInt);
  235. Procedure Insert(const source:string;Var s:string;index:StrLenInt);
  236. Function  Pos(const substr:string;const s:string):byte;
  237. Function  Pos(C:Char;const s:string):byte;
  238. Function  upCase(c:Char):Char;
  239. Function  upCase(const s:string):string;
  240. {$ifndef RTLLITE}
  241. Function  lowerCase(c:Char):Char;
  242. Function  lowerCase(const s:string):string;
  243. Function  hexStr(Val:Longint;cnt:byte):string;
  244. Function  binStr(Val:Longint;cnt:byte):string;
  245. {$endif RTLLITE}
  246. Function  Space(b:byte):string;
  247. Procedure Val(const s:string;Var l:Longint;Var code:Word);
  248. Procedure Val(const s:string;Var l:Longint;Var code:Integer);
  249. Procedure Val(const s:string;Var l:Longint);
  250. Procedure Val(const s:string;Var b:byte;Var code:Word);
  251. Procedure Val(const s:string;Var b:byte;Var code:Integer);
  252. Procedure Val(const s:string;Var b:byte);
  253. Procedure Val(const s:string;Var b:shortint;Var code:Word);
  254. Procedure Val(const s:string;Var b:shortint;Var code:Integer);
  255. Procedure Val(const s:string;Var b:shortint);
  256. Procedure Val(const s:string;Var b:Word;Var code:Word);
  257. Procedure Val(const s:string;Var b:Word;Var code:Integer);
  258. Procedure Val(const s:string;Var b:Word);
  259. Procedure Val(const s:string;Var b:Integer;Var code:Word);
  260. Procedure Val(const s:string;Var b:Integer;Var code:Integer);
  261. Procedure Val(const s:string;Var b:Integer);
  262. Procedure Val(const s:string;Var v:cardinal;Var code:Word);
  263. Procedure Val(const s:string;Var v:cardinal;Var code:Integer);
  264. Procedure Val(const s:string;Var v:cardinal);
  265. Procedure Val(const s:string;Var d:ValReal;Var code:Word);
  266. Procedure Val(const s:string;Var d:ValReal;Var code:Integer);
  267. Procedure Val(const s:string;Var d:ValReal);
  268. {$ifdef SUPPORT_SINGLE}
  269.   Procedure Val(const s:string;Var d:single;Var code:Word);
  270.   Procedure Val(const s:string;Var d:single;Var code:Integer);
  271.   Procedure Val(const s:string;Var d:single);
  272. {$endif SUPPORT_SINGLE}
  273. {$ifdef SUPPORT_COMP}
  274.   Procedure Val(const s:string;Var d:comp;Var code:Word);
  275.   Procedure Val(const s:string;Var d:comp;Var code:Integer);
  276.   Procedure Val(const s:string;Var d:comp);
  277. {$endif SUPPORT_COMP}
  278. {$ifdef DEFAULT_EXTENDED}
  279.   Procedure Val(const s:string;Var d:Real;Var code:Word);
  280.   Procedure Val(const s:string;Var d:Real;Var code:Integer);
  281.   Procedure Val(const s:string;Var d:Real);
  282. {$else DEFAULT_EXTENDED}
  283.   {$ifdef SUPPORT_EXTENDED}
  284.     Procedure Val(const s:string;Var d:Extended;Var code:Word);
  285.     Procedure Val(const s:string;Var d:Extended;Var code:Integer);
  286.     Procedure Val(const s:string;Var d:Extended);
  287.   {$endif}
  288. {$endif DEFAULT_EXTENDED}
  289.  
  290. {****************************************************************************
  291.                              AnsiString Handling
  292. ****************************************************************************}
  293.  
  294. {$ifdef UseAnsiStrings }
  295.  
  296. Procedure SetLength (Var S : AnsiString; l : Longint);
  297. Procedure UniqueAnsiString (Var S : AnsiString);
  298. Function  Length (Var S : AnsiString) : Longint;
  299. Function  Copy (Var S : AnsiString; Index,Size : Longint) : AnsiString;
  300. Function  Pos (Var Substr : AnsiString; Var Source : AnsiString) : Longint;
  301. Procedure Insert (Var Source : AnsiString; Var S : AnsiString; Index : Longint);
  302. Procedure Delete (Var S : AnsiString; Index,Size: Longint);
  303. Procedure Val (Var S : AnsiString; var R : real; Var Code : Integer);
  304. {
  305. Procedure Val (Const S : AnsiString; var D : Double; Var Code : Integer);
  306. }
  307. Procedure Val (Var S : AnsiString; var E : Extended; Code : Integer);
  308. Procedure Val (Var S : AnsiString; var C : Cardinal; Code : Integer);
  309. Procedure Val (Var S : AnsiString; var L : Longint; Var Code : Integer);
  310. Procedure Val (Var S : AnsiString; var W : Word; Var Code : Integer);
  311. Procedure Val (Var S : AnsiString; var I : Integer; Var Code : Integer);
  312. Procedure Val (Var S : AnsiString; var B : Byte; Var Code : Integer);
  313. Procedure Val (Var S : AnsiString; var SI : ShortInt; Var  Code : Integer);
  314. {
  315. Procedure Str (Const R : Real;Len, fr : longint; Var S : AnsiString);
  316. Procedure Str (Const D : Double;Len,fr : longint; Var S : AnsiString);
  317. Procedure Str (Const E : Extended;Len,fr : longint; Var S : AnsiString);
  318. Procedure Str (Const C : Cardinal;len : Longint; Var S : AnsiString);
  319. Procedure Str (Const L : LongInt;len : longint; Var S : AnsiString);
  320. Procedure Str (Const W : Word;len : longint; Var S : AnsiString);
  321. Procedure Str (Const I : Integer;len : Longint; Var S : AnsiString);
  322. Procedure Str (Const B : Byte; Len : longint; Var S : AnsiString);
  323. Procedure Str (Const SI : ShortInt; Len : longint; Var S : AnsiString);
  324. }
  325. {$endif}
  326.  
  327.  
  328. {****************************************************************************
  329.                           Untyped File Management
  330. ****************************************************************************}
  331.  
  332. Procedure Assign(Var f:File;const Name:string);
  333. Procedure Assign(Var f:File;p:pchar);
  334. Procedure Assign(Var f:File;c:char);
  335. Procedure Rewrite(Var f:File;l:Word);
  336. Procedure Rewrite(Var f:File);
  337. Procedure Reset(Var f:File;l:Word);
  338. Procedure Reset(Var f:File);
  339. Procedure Close(Var f:File);
  340. Procedure BlockWrite(Var f:File;Var Buf;Count:Longint;Var Result:Longint);
  341. Procedure BlockWrite(Var f:File;Var Buf;Count:Word;Var Result:Word);
  342. Procedure BlockWrite(Var f:File;Var Buf;Count:Word;Var Result:Integer);
  343. Procedure BlockWrite(Var f:File;Var Buf;Count:Longint);
  344. Procedure BlockRead(Var f:File;Var Buf;count:Longint;Var Result:Longint);
  345. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Word);
  346. Procedure BlockRead(Var f:File;Var Buf;count:Word;Var Result:Integer);
  347. Procedure BlockRead(Var f:File;Var Buf;count:Longint);
  348. Function  FilePos(Var f:File):Longint;
  349. Function  FileSize(Var f:File):Longint;
  350. Procedure Seek(Var f:File;Pos:Longint);
  351. Function  EOF(Var f:File):Boolean;
  352. Procedure Erase(Var f:File);
  353. Procedure Rename(Var f:File;const s:string);
  354. Procedure Rename(Var f:File;p:pchar);
  355. Procedure Rename(Var f:File;c:char);
  356. Procedure Truncate (Var F:File);
  357.  
  358. {****************************************************************************
  359.                            Typed File Management
  360. ****************************************************************************}
  361.  
  362. Procedure Assign(Var f:TypedFile;const Name:string);
  363. Procedure Assign(Var f:TypedFile;p:pchar);
  364. Procedure Assign(Var f:TypedFile;c:char);
  365. Procedure Rewrite(Var f:TypedFile);
  366. Procedure Reset(Var f:TypedFile);
  367.  
  368. {****************************************************************************
  369.                             Text File Management
  370. ****************************************************************************}
  371.  
  372. Procedure Assign(Var t:Text;const s:string);
  373. Procedure Assign(Var t:Text;p:pchar);
  374. Procedure Assign(Var t:Text;c:char);
  375. Procedure Close(Var t:Text);
  376. Procedure Rewrite(Var t:Text);
  377. Procedure Reset(Var t:Text);
  378. Procedure Append(Var t:Text);
  379. Procedure Flush(Var t:Text);
  380. Procedure Erase(Var t:Text);
  381. Procedure Rename(Var t:Text;const s:string);
  382. Procedure Rename(Var t:Text;p:pchar);
  383. Procedure Rename(Var t:Text;c:char);
  384. Function  EOF(Var t:Text):Boolean;
  385. Function  EOF:Boolean;
  386. Function  EOLn(Var t:Text):Boolean;
  387. Function  EOLn:Boolean;
  388. Function  SeekEOLn (Var F:Text):Boolean;
  389. Function  SeekEOF (Var F:Text):Boolean;
  390. Function  SeekEOLn:Boolean;
  391. Function  SeekEOF:Boolean;
  392. Procedure SetTextBuf(Var f:Text; Var Buf);
  393. Procedure SetTextBuf(Var f:Text; Var Buf; Size:Word);
  394.  
  395. {****************************************************************************
  396.                             Directory Management
  397. ****************************************************************************}
  398.  
  399. Procedure chdir(const s:string);
  400. Procedure mkdir(const s:string);
  401. Procedure rmdir(const s:string);
  402. Procedure getdir(drivenr:byte;Var dir:string);
  403.  
  404. {*****************************************************************************
  405.                              Miscelleaous
  406. *****************************************************************************}
  407.  
  408. Function IOResult:Word;
  409. Function Sptr:Longint;
  410.  
  411. {*****************************************************************************
  412.                           Init / Exit / ExitProc
  413. *****************************************************************************}
  414.  
  415. Function  Paramcount:Longint;
  416. Function  ParamStr(l:Longint):string;
  417. {$ifndef RTLLITE}
  418. Procedure Dump_Stack(bp:Longint);
  419. {$endif RTLLITE}
  420. Procedure RunError(w:Word);
  421. Procedure RunError;
  422. Procedure halt(errnum:byte);
  423. {$ifndef RTLLITE}
  424. Procedure AddExitProc(Proc:TProcedure);
  425. {$endif RTLLITE}
  426. Procedure halt;
  427.  
  428. {*****************************************************************************
  429.                           SetJmp/LongJmp
  430. *****************************************************************************}
  431.  
  432. {$i setjumph.inc}
  433.  
  434. {
  435.   $Log: systemh.inc,v $
  436.   Revision 1.24  1998/08/11 21:39:08  peter
  437.     * splitted default_extended from support_extended
  438.  
  439.   Revision 1.23  1998/08/11 00:05:27  peter
  440.     * $ifdef ver0_99_5 updates
  441.  
  442.   Revision 1.22  1998/08/08 12:28:14  florian
  443.     * a lot small fixes to the extended data type work
  444.  
  445.   Revision 1.21  1998/07/30 13:26:17  michael
  446.   + Added support for ErrorProc variable. All internal functions are required
  447.     to call HandleError instead of runerror from now on.
  448.     This is necessary for exception support.
  449.  
  450.   Revision 1.20  1998/07/28 20:37:47  michael
  451.   + added setjmp/longjmp and exception support
  452.  
  453.   Revision 1.19  1998/07/20 23:36:57  michael
  454.   changes for ansistrings
  455.  
  456.   Revision 1.18  1998/07/18 17:14:24  florian
  457.     * strlenint type implemented
  458.  
  459.   Revision 1.17  1998/07/10 11:02:39  peter
  460.     * support_fixed, becuase fixed is not 100% yet for the m68k
  461.  
  462.   Revision 1.16  1998/07/02 12:13:18  carl
  463.     * No SINGLE type for m68k or other non-intel processors!
  464.  
  465.   Revision 1.15  1998/07/01 14:43:46  carl
  466.     - max_frame_dump reduced to 8, 20 is too much!
  467.  
  468.   Revision 1.14  1998/06/25 14:04:26  peter
  469.     + internal inc/dec
  470.  
  471.   Revision 1.13  1998/06/25 09:44:21  daniel
  472.   + RTLLITE directive to compile minimal RTL.
  473.  
  474.   Revision 1.12  1998/06/15 15:16:27  daniel
  475.  
  476.   * RTLLITE conditional added to produce smaller RTL
  477.  
  478.   Revision 1.11  1998/06/08 12:38:23  michael
  479.   Implemented rtti, inserted ansistrings again
  480.  
  481.   Revision 1.10  1998/06/04 23:46:02  peter
  482.     * comp,extended are only i386 added support_comp,support_extended
  483.  
  484.   Revision 1.9  1998/06/04 08:26:03  pierre
  485.     * boolean internal definition again (needed to compile
  486.       older RTL's)
  487.  
  488.   Revision 1.8  1998/06/03 23:39:53  peter
  489.     + boolean=bytebool
  490.  
  491.   Revision 1.7  1998/05/22 12:34:11  peter
  492.     * fixed the optimizes of daniel
  493.  
  494.   Revision 1.6  1998/05/21 19:31:00  peter
  495.     * objects compiles for linux
  496.     + assign(pchar), assign(char), rename(pchar), rename(char)
  497.     * fixed read_text_as_array
  498.     + read_text_as_pchar which was not yet in the rtl
  499.  
  500.   Revision 1.5  1998/05/12 10:42:45  peter
  501.     * moved getopts to inc/, all supported OS's need argc,argv exported
  502.     + strpas, strlen are now exported in the systemunit
  503.     * removed logs
  504.     * removed $ifdef ver_above
  505.  
  506.   Revision 1.4  1998/04/16 12:30:47  peter
  507.     + inc(pchar), dec(pchar), incc(pchar,a),dec(pchar,a)
  508. }
  509.